Repository navigation
Browse and restore Trash in the TUI - #672
WhiskeyTuesday wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
A pending Trash refresh can reinsert a restored topic after navigation because an early return skips request invalidation; the ordering needs a fix and regression test.
1 open issue
What changed in this PR
Adds Trash browsing and restoration to the TUI’s existing mail navigation, while keeping Trash topic IDs separate from posting IDs.
Changes:
- Adds a
0 Trashtab with pagination, thread reading, andito restore. - Blocks posting mutations in Trash and adds tests for restore outcomes, stale responses, and ID collisions.
- Documents the behavior and temporarily pins an SDK fork for pagination support; a published SDK release is required before merging.
[!TIP]
If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or rungh pr ready --undo.
Click "Ready for review" or rungh pr readyto reengage.
| File | Description |
|---|---|
internal/tui/tui_test.go |
Updates source-count expectations for Trash. |
internal/tui/trash.go |
Implements restoration, mutation restrictions, and contextual help. |
internal/tui/trash_test.go |
Tests navigation, pagination, restoration, and identity safeguards. |
internal/tui/move.go |
Excludes Trash from move destinations. |
internal/tui/mail.go |
Integrates Trash navigation, reading, and action guards. |
internal/tui/mail_test.go |
Adjusts mail-source expectations for Trash. |
internal/tui/collections_test.go |
Accounts for Trash during collection discovery. |
internal/mail/source.go |
Adds the Trash source kind. |
internal/mail/page.go |
Adapts paginated Trash topics into list rows. |
go.sum |
Records checksums for the temporary SDK fork. |
go.mod |
Pins the SDK fork containing pagination support. |
docs/tui.md |
Documents Trash controls and restrictions. |
docs/architecture/mail-sources-and-paging.md |
Explains Trash identities and restore behavior. |
Review effort: Balanced
| if v.currentSourceKind() != mail.KindTrash { | ||
| return notify("Thread restored") | ||
| } | ||
| // A page or live head read begun before the restore may still contain this | ||
| // topic. Ignore those answers so they cannot resurrect the restored row. | ||
| v.moreRequestID++ | ||
| v.liveRequestID++ |
There was a problem hiding this comment.
Fixed in 8466640. Confirmed the reported ordering: A pre-restore Trash live refresh could still pass the request/source checks after a round trip through the Imbox: navigation invalidates paginated reads but does not change the live refresh generation.
The fix moves live-refresh invalidation ahead of the non-Trash early return, still after the restore error check. Paging invalidation remains scoped to Trash so a late restore does not interfere with the other source's page read.
The new regression holds an actual SDK refresh response from an offline test server, starts a restore with i, navigates to the Imbox, completes the successful restore, returns to a freshly read Trash list, and then delivers the old response. It reproduced the restored topic reappearing before the fix and now rejects that response. A separate test checks that a failed restore still allows an otherwise valid refresh.
TUI/mail tests, the targeted race check, and lint pass. The full test suite still hits the previously observed TestFindBareLinksPastRejectedPrefixesIsLinear timing failure; the new regressions pass.
8466640 to
886301e
Compare
886301e to
f429577
Compare

The TUI can send mail to Trash but cannot browse it or restore a thread. Add a
0 Trashtab, with paginated browsing, thread reading, andito restore through HEY's normal topic restore operation.Trash returns topics rather than posting IDs. The adapter preserves that distinction, blocks posting mutations in Trash, and avoids marking a trashed topic as a seen posting. A restored row leaves the list only after success. Earlier page and live reads cannot bring it back, including after switching sources, and late restore responses cannot remove an unrelated row from another source.
Uses released HEY SDK v0.37.0 for Trash pagination and total counts. The temporary SDK fork replacement has been removed.
make checkpasses. Tests cover navigation, opaque pagination, total counts, empty pages, opening without a posting observation, restore success and failure, blocked mutations, stale reads, and topic/posting ID collisions.Summary by cubic
Adds a Trash tab (shortcut
0) to the TUI so trashed threads can be browsed, read, and restored withi. Previously Trash was write-only: mail could be sent there, but there was no way to browse or restore it.Trash serves topics rather than posting IDs. The adapter keeps that distinction — posting mutations are blocked in Trash, and a trashed topic is never observed as a seen posting. A successful restore removes the row, closes any open reader, and invalidates any read begun earlier, so a stale page or live response cannot resurrect the restored row even after the reader switches sources and back. A failed restore leaves the thread in place to retry and keeps any in-flight refresh valid. Trash is excluded as a move destination. Tests cover navigation, opaque pagination, restore success and failure, blocked mutations, stale reads, and topic/posting ID collisions.
Dependencies
Topics.GetTrashPagefrom the released HEY SDK; the temporarygo.modreplaceto the fork commit has been removed.Written for commit f429577. Summary will update on new commits.